function user_fast_exam()
{ 
   var _strPage=DOMAIN_NAME+'fast_exam.php';
   var _currentID;
   var _inteval;
   var _curranwser='';
   var _totalques=0;
   var _cd;
   var _rk;
   var _scr;
   var _limitTime=0;
   var _totalTime=200;
   var _listRankTemp;
   var _completeExam;//kiem tra hoan thanh bài kiem tra
   
   var _arrNX=new Array();
   _arrNX[0]="Please review and retake the exam!";
   _arrNX[1]="Please review and retake the exam!";
   _arrNX[2]="Please review and retake the exam!";
   _arrNX[3]="Please review and retake the exam!";
   _arrNX[4]="Please review and retake the exam!";
   _arrNX[5]="Go for it!";
   _arrNX[6]="Go for it!";
   _arrNX[7]="Go for it!";
   _arrNX[8]="You're good!";
   _arrNX[9]="That’s awesome! ";
   _arrNX[10]="Congratulation! Well done!";
   
   
   this.initControl       =   initControl;
   this.startExam         =   startExam;
   this.getSuggest        =   getSuggest;
   this.nextSent          =   nextSent;
   this.formatInputText   =   formatInputText;
   this.finishExam        =   finishExam;
   this.distroyEventControl=  distroyEventControl;
   this.log               =   log; 
   this.saveScoreForRank  =   saveScoreForRank;
   this.saveScoreForRank_OnCallBack=saveScoreForRank_OnCallBack;
   this.inviteFriends     =   inviteFriends;
   this.shuffle           =   shuffle;
   this.getListRank       =   getListRank;
   this.getListRank_OnCallBack=getListRank_OnCallBack;
   
   this.upload2FB=upload2FB;
   
   this.openLoginPopup=openLoginPopup;
   this.checkCompleteExam=checkCompleteExam;
   
   function checkCompleteExam(){
        if(objFastExam._completeExam==0)
            return 'This page is asking you to confirm that you want to leave - data you have entered may not be saved';
        return ;
   }
   
   function openLoginPopup(pic,cap,acct)
   {
        FB.login(function(response) {
           // handle the response
           upload2FB(pic, cap, acct);
         }, {scope: 'publish_stream,user_photos'});
         popDiv.hide();
   }
   
  
   
   function upload2FB(picture, caption, accessToken)
   {
        $.ajax({
            type: 'POST',
            url: _strPage,
            dataType: 'text',
            data: {"act" : "upload-image-to-facebook", "picture" : picture, "caption" : caption,'accessToken':accessToken},
            success: function (data) {                                    
                
                if (data == 0) {
                    //alert('Không lấy được thông tin');
                } else if (data == 1) {
                    inviteFriends();
                }
            }
        });
   
   }
   function getListRank()
    {
        var strRequest='iaAJ=1&act=get-rank';
	    var ajax = new Ajax();
	    
	    ajax.SendRequestToServerWithCustomMsg(_strPage,strRequest, getListRank_OnCallBack, true, MSG_AJAX_SENDING_VN);
    }
    function getListRank_OnCallBack(xmlHTTPRequest)
    {
	    if(xmlHTTPRequest.readyState == 4) 
	    {
		    if(xmlHTTPRequest.status == 200) 
		    {			

			    var strRespond = parserXML(xmlHTTPRequest.responseText);		        
    	        
			    if(parseInt(strRespond[1]["rs"])==1) // is add succeed
			    { 		
    				$("#topuseroftheday").html(strRespond[1]["listtop"]);
    				_listRankTemp='';
			    }
			    else
			    {
			        $("#topuseroftheday").html(_listRankTemp);
				     popDiv.alert('Không lấy được thông tin!!!');
			    }
    	        
		    }
	    }
    }
   
   
   function shuffle(o){
        for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
        return o;
    };  
   function inviteFriends(){
        var friend_uids = [];
        FB.api('/me/friends', function(response){
            if(response && response.data)
            {
                for(var i = 0; i < response.data.length; i++)
                {
                    var friend = response.data[i];
                    friend_uids.push(friend.id);
                }
                shuffle(friend_uids);
                var tos = '';
                for(var j = 0; j < Math.min(friend_uids.length, 25); j++)
                {
                    tos = tos + friend_uids[j] + ',';
                }
                //an div
                popDiv.hide();
                FB.ui({
                    display: 'iframe',
                    method: 'apprequests',
                    new_style_message:true,
                    title:'Click "Send Request" để mời bạn bè cùng tham gia!',
                    message: "mời bạn tham gia",
                    to: friend_uids.slice(0,45)
                }, function(data){
                    if(data){
                        var r=confirm("Bạn có muốn tiếp tục mời them bạn bè tham gia?");
                        if (r==true)
                        {
                            inviteFriends();
                        }
                        else
                        {
                          
                        }
                        //counts=counts-1;
                        //if(counts>0) sendrequest(counts)
                    }
                    else { 
                        //$('#loading').hide(); 
                        //$('#result').hide(); 
                        //$('#pal').show();
                        //alert("Bạn phải click vào 'Send Request' mới xem được ảnh. Click vào Xem kết quả và thử lại nhé :) "); 
                    }
                });
            }
            else
            {
                
            }
        });
   
        
    }
 
    
   
   function saveScoreForRank(key,sc,tp)
    {
        _listRankTemp=$("#topuseroftheday").html();
        $("#topuseroftheday").html('<img src="'+DOMAIN_NAME+'images/loadingfb.gif">');
        var strRequest='isAJ=1&act=sc&tk='+key+'&sc='+sc+'&tp='+tp;
	    var ajax = new Ajax();
	    //alert('course.php'+strRequest); 
	    ajax.SendRequestToServerWithCustomMsg(_strPage,strRequest, saveScoreForRank_OnCallBack, true, MSG_AJAX_SENDING_VN);
    }
    function saveScoreForRank_OnCallBack(xmlHTTPRequest)
    {
	    if(xmlHTTPRequest.readyState == 4) 
	    {
		    if(xmlHTTPRequest.status == 200) 
		    {			

			    var strRespond = parserXML(xmlHTTPRequest.responseText);		        
    	        
			    if(parseInt(strRespond[1]["rs"])==1) // is add succeed
			    { 		
    				if(parseInt(strRespond[1]["isLogin"])==0) // is not login
			        {
			            $("#ConnerSignIn .signin").click();
			        }
			        else
			        {
			            getListRank();
			            popDiv.alert('<div>Bạn đã lưu điểm thành công!<br>Bấm OK để chia sẻ kết quả lên Facebook<br></div><center><div id="loadFaceBookImg"></div></center>','Thông báo',2, function(){
			               
			               $("#loadFaceBookImg").html('<img src="'+DOMAIN_NAME+'images/loadingfb.gif">');
			               window.fbAsyncInit = function() {
				                 
                                 FB.init({
				                    appId      : '373677049333656',
				                    status     : true, 
				                    cookie     : true,
				                    xfbml      : true,
				                    oauth      : true
			                      });
				                  FB.getLoginStatus(function(response) {
				                    
                                      if (response.status === 'connected') {
                                        
                                        var uid = response.authResponse.userID;
                                        var accessToken = response.authResponse.accessToken;
                                       
                                        
                                        upload2FB(strRespond[1]["picture"], strRespond[1]["caption"], accessToken);
                                       
                                        
                                        
                                      } else if (response.status === 'not_authorized') {
                                           $("#loadFaceBookImg").parent().prev().remove();
                                           $("#loadFaceBookImg").parent().html('Bạn chưa xác nhận ứng dụng. Bấm vào đây để xác nhận <br><a href="#" id="bntLoginFacbookPopup" onclick="return false;" ><img src="'+DOMAIN_NAME+'images/facebookrequestforpermission.png"></a>');
                                           $("#bntLoginFacbookPopup").click(function(){objFastExam.openLoginPopup(strRespond[1]["picture"], strRespond[1]["caption"], accessToken);});
                                      } else {
                                           $("#loadFaceBookImg").parent().prev().remove();
                                           $("#loadFaceBookImg").parent().html('Bạn chưa đăng nhập. Bấm vào đây để đăng nhập <br><a href="#" id="bntLoginFacbookPopup" onclick="return false;" ><img src="'+DOMAIN_NAME+'images/facebooklogin.png"></a>');
                                           $("#bntLoginFacbookPopup").click(function(){objFastExam.openLoginPopup(strRespond[1]["picture"], strRespond[1]["caption"], accessToken);});
                                            
                                      }
                                     });
                                     
				                };

				                (function(d){
				                   var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
				                   js = d.createElement('script'); js.id = id; js.async = true;
				                   js.src = "//connect.facebook.net/en_US/all.js";
				                   d.getElementsByTagName('head')[0].appendChild(js);
				                 }(document));
			               
			            });
			            
			        }
			    }
			    else
			    {
				     popDiv.alert('Không lấy được thông tin!!!');
			    }
    	        
		    }
	    }
    }
   
   
   
    function log(content)
    {
      return;
        console.log(content);
    }
   function distroyEventControl()
   {
        $("#txt-anwser-parent .txt-anwser-item").unbind("keypress");
        $("#txt-anwser").unbind("keypress");
        $(".anws-exam").unbind("click");
        $(".txt-anwser").unbind("focusout");
        $(".txt-anwser").unbind("keypress");
        $(".anws-exam b").unbind("click");
        $(".txt-anwser").unbind("focusout");
        $(".txt-anwser").unbind("keypress");
   }
   
   function finishExam()
   {

        //remove sự kiện click vào div anwser
        distroyEventControl();
        
        //clear het textbox
        $(".item-exam .anws-exam input").parent().html($(".item-exam .anws-exam input").val());
        //ngưng thoi gian countdown
        clearInterval(_inteval);
       
        
        var eid=hashObj.getParameter("eid");
        var did=hashObj.getParameter("did");
     
        var strPos='';
        
        $(".item-exam .cont-exam .anws-exam").each(function(){
            var id=$(this).parent().parent().attr("id");
            id=parseInt(id.replace('item_answser_',''))-1;
            strPos+='&arrinfo['+id+']='+($(this).html());
           
        });
        
        //cham diem
        var strarrr='';
     
        $("#lst-answered-2 .anws-exam").each(function(){
            var val=$(this).text();
            var eid=$(this).attr("eid");
            var valda=$("#correct-answer-content .correct-answer[eid='"+eid+"']").text();
            
            if($.trim(val.replace(/\s{2,}/g, ' ').toLowerCase()) == $.trim(valda.replace(/\s{2,}/g, ' ').toLowerCase() )  )
			{
			    strarrr+=eid+',';
			}
        });
        strarrr=strarrr.substring(0,strarrr.length-1);
        
        
        //finish
        
        //var strarrw=strRespond[1]["arrwrong"];
        var arrR=strarrr.split(',');
        //var arrW=strarrw.split(',');
        var numright=10;
        
        if(strarrr)
        {
            numright=arrR.length;
        }

        var score=numright*(10/objFastExam._totalques);
       
        
        //gán dấu tick cho các câu đúng sai
        $("#lst-answered-2 .item-exam .nums-exam b").addClass("icon-x");
        $.each(arrR,function(index,value){
            //alert(value);
           
                $("#item_answser_"+(value)+" .nums-exam b").removeClass("icon-x");
                $("#item_answser_"+(value)+" .nums-exam b").addClass("icon-tick");
                $("#item_answser_"+(value)+" .vn_result").show();
                
            
        });
        
        //lấy câu nhận xét
        var x=score;
        _scr=parseFloat(score);
        var y=Math.floor(x);
        var timePlay=(20);
        
        $("#note-finished").html(
            '<div id="result_exam_info">'
            + '<fieldset style="border:solid 1px #ccc;padding:5px;padding-top:0px;">'
            + '<legend style="padding:5px;margin-left:10px;"><h2 style="font-size:25px">Kết quả</h2></legend>'
            + '<div class="resultinfo" style="margin:5px"><b> - Số điểm:</b> <span style="font-size:30px;">'+parseFloat(score)+' điểm </span></div>'
            + '<div class="resultinfo" style="margin:5px"><b> - Thời gian hoàn thành:</b> <span style="font-size:25px;">'+timePlay+'s</em></div>'
            + '<div class="resultinfo" style="margin:5px"><b> - Số câu đúng:</b> <span style="font-size:25px;">'+numright+'/'+objFastExam._totalques+'</span></div>'
            //+ '<div class="resultinfo" style="font-size:30px;color:#82AD17;margin: 30px 5px 5px !important;">"'+_arrNX[y]+'"</div>'
            + '<div class="controller" style="margin:5px">'         
            + '     <input class="btn btn-green" type="button" func="re-exam" value="Làm lại"> '           			            
            + '     <input class="btn btn-green" type="button" func="save-score-for-rank" value="Xếp hạng"> '   
            + '</div>'
            + '</fieldset>'
            + '</div>'
        );
        
       
        //xoa control
        $("#exam-parent #note").remove();
        
        $("#bnt-control").remove();
        $(".status-control").remove();
        
        
        $("#result_exam_info input[func='re-exam']").click(function(){
            popDiv.alert("Bạn muốn làm lại?","Thông báo",2,function(){
                window.location.reload();    
            });
        
        
        });
        $("#result_exam_info input[func='save-score-for-rank']").click(function(){
            $(this).unbind("click");
            $(this).addClass("disabled");
            
            saveScoreForRank($("#page-content").attr('timekey'),_scr,(20));
        });
        
        var doSehh= function(){
            $("#result_exam_info input[func='save-score']").animate({'background-color':'#82AD17'},1000).animate({'background-color':'#E57E00'},1000,function(){timeOut = setTimeout(doSehh,2000)});
        }
        $("#result_exam_info input[func='save-score']").animate({'background-color':'#82AD17'},1000).animate({'background-color':'#E57E00'},1000,doSehh);
        
        objFastExam._completeExam=1;
	    
   }
   
   function nextSent()
   {       
                   
            
            //lấy id current
            var currID=parseInt(objFastExam._currentID);        
            
            var flagIsNull=0;
            $("#txt-anwser-parent .txt-anwser-item").each(function(){
                  if($(this).val()=='')
                  {
                        flagIsNull++;                        
                  }
            });
            
            if(flagIsNull!=0)
            {
                popDiv.alert("Bạn còn "+flagIsNull+" chỗ trống chưa điền!","Chú ý",1,function(){
                    
                    initControl();  
                    //$("#txt-anwser-parent .txt-anwser-item[value='']").last().focus();
                    $("#txt-anwser-parent .txt-anwser-item").each(function(){
                        if($(this).val()=='')
                        {
                            $(this).focus();
                            
                        }
                    });
                });
                              
                return;
            }
            
            try{
                if (basicMP3Player.lastSound) 
	                basicMP3Player.stopSound(basicMP3Player.lastSound);
                basicMP3Player.handleClick({'target':$("#lst-exam-question").find('.lst-exam-question-item .sm2_button')[(objFastExam._currentID)]});
            }
		    catch(e){
		        //alert(e.message);
		    }
		    
            //thay thế các tag
            $("#txt-anwser-parent .txt-anwser-item").each(function(){
                $(this).replaceWith('<b style="color:green;cursor:pointer">'+formatInputText($.trim($(this).val()))+'</b>');
            });
            //lấy giá trị gán xuống dưới
            var rsanwser=$("#txt-anwser-parent").html();
            
            
            
            //$("#txt-anwser").val('');
            //$("#txt-anwser").focus();
            $("#txt-anwser-parent .txt-anwser-item").val('');
            
            //tạo object
            var objBlock=$("#block_item_"+currID); 
            
            if(currID<objFastExam._totalques)
            {   
                //gán lại id current
                var temp=$(objBlock).next().attr("id");
                if(typeof(objFastExam._currentID)!='undefined')
                {
                    //objFastExam._currentID=parseInt(temp.replace("block_item_",""));
                    objFastExam._currentID++;
                }
            }
                           
            var options={};
            $(objBlock).fadeOut("fast",function(){            
                if(currID==objFastExam._totalques)
                {                
                    //currID++;

                    //add xuống duoi và clear textbox
                    $("#item_answser_"+currID).find("div[class='anws-exam']").html(rsanwser);
                    //add thêm cái eid cho div này
                    $("#item_answser_"+currID).find("div[class='anws-exam']").attr("eid",currID);
                    
                    
                    //fade in                 
                    $("#lst-answered-2").prepend($("#item_answser_"+currID));
                    $("#lst-answered-2").find("#item_answser_"+currID).fadeIn("fast");
                    
                    //cap nhat lại số cau hien tai
                    $("#nums-ques").html(objFastExam._currentID);
                    
                    //init lai cac control
                    initControl();
                    
                    //disable button next
                    $("input[func='next']").addClass("disabled");
                    $("input[func='next']").unbind("click");
                    
                    //enable submit
                    $("input[func='submit']").removeClass("disabled");
                    $("input[func='submit']").click(function(){
                    
                        finishExam();
                    });
                    
                    //disable textbox
                    $("#txt-anwser-parent .input").attr("disabled","disabled");
                    
                    //disable question content
                    $("table[class='exam-content']").fadeOut("fast",function(){
                        //show note
                        $("div[id='note-finished']").fadeIn("slow");
                    });
                    
                }
                else
                {                
                    $(objBlock).next().fadeIn( "slow", function(){
                       //call back
                       //add xuống duoi và clear textbox
                       $("#item_answser_"+currID).find("div[class='anws-exam']").html(rsanwser);
                       //add thêm cái eid cho div này
                       $("#item_answser_"+currID).find("div[class='anws-exam']").attr("eid",currID);
                    
                       //fade in
                       $("#lst-answered-2").prepend($("#item_answser_"+currID));
                        $("#lst-answered-2").find("#item_answser_"+currID).fadeIn("fast"); 
                       
                       //cap nhat lại số cau hien tai
                       $("#nums-ques").html(objFastExam._currentID);
                       
                       //init lai cac control
                       initControl();
                    });
                 }
            });
        
        
            objFastExam.getSuggest(currID);
       
        
        
   }
   function formatInputText(txtAnwser)
   {
        txtAnwser=txtAnwser.replace(/</g,"&lt;");
        txtAnwser=txtAnwser.replace(/>/g,"&gt;");
        txtAnwser=txtAnwser.replace(/\'/g,"&#39;");
        txtAnwser=txtAnwser.replace(/"/g,"&quot;");
        return txtAnwser;
   }
   
   function getSuggest(id)
   {
        //lấy gợi ý quăng vào text box
        var text=$($("#suggest-content .suggest")[id]).html();
        
        if(!text)
        {
            return;
        }
        //$("#txt-anwser").val(text);
       //hight light ____
       //$("#txt-anwser").caret(/\_+/g);
       var objParent=$("#txt-anwser-parent");
       
       var content=text.replace(/\_+/g,'<input type="text" class="txt-anwser-item">');
       $(objParent).html(content);
       
       //set focus
  //     if($.bre)
        setTimeout(function () {
          //$('.my-thing').focus();
          $($("#txt-anwser-parent .txt-anwser-item")[0]).focus();
        }, 100);

//       $($("#txt-anwser-parent .txt-anwser-item")[0]).focus();
       
   }
   
   function startExam()
   {
        SetCookie('fastexamplaycount', 1, 360,true); 
        objFastExam._completeExam=0;
        //ẩn div
        $("#welcome-screen").fadeOut("slow",function(){
            //hiên exam
            $("div[id='exam-parent']").fadeIn("slow",function(){                
                try{                    
                    basicMP3Player.handleClick({'target':$("#lst-exam-question").find('.lst-exam-question-item .sm2_button')[0]});
                }
			    catch(e){}
                //load suggest
                objFastExam.getSuggest(0);
                    
                
                //init control
                initControl();
                
                //khoi tao time
                var d = new Date();
                
                var stT=d.getTime();
                var stT1=objFastExam._cd*1000;
                _limitTime=stT+stT1;
                
                _rk=stT;
                //console.log("Thời gian giới hạn: "+d.getTime()+' | '+objFastExam._cd);
                //chạy count down;                    
                if(typeof(_inteval)=='undefined'){
                
                        _inteval=self.setInterval(function(){
                            //alert('aaa');
                            var d = new Date();
                            //alert(d.getTime());
                            //console.log(_limitTime+' | '+d.getTime());
                            var sttT=d.getTime();
                            //log(_rk+' | '+sttT);
                            if(_rk>sttT)
                            {
                                //disable textbox
                                $("input[id='txt-anwser']").attr("disabled","disabled");
                                
                                //disable question content
                                $("table[class='exam-content']").fadeOut("fast",function(){
                                    //show note
                                    $("div[id='note-finished']").fadeIn("slow");
                                    finishExam();
                                });
                            }
                            else
                            {
                                _rk=sttT;
                            }
                            
                            var kcTime =_limitTime-sttT;
                            kcTime=Math.floor(kcTime/1000);
                            if(kcTime>=0)
                            {
                            
                                $("#time-countdown").html(kcTime);
                                
                            }                            
                            else
                            {
                                //disable textbox
                                $("input[id='txt-anwser']").attr("disabled","disabled");
                                
                                //disable question content
                                $("table[class='exam-content']").fadeOut("fast",function(){
                                    //show note
                                    $("div[id='note-finished']").fadeIn("slow");
                                    
                                    finishExam();
                            });
                            
                        }
                    },500);
                    
                }
            });
        });
   }
   
   function initControl()
   {
   
        $(".txt-anwser-item").unbind('keydown');
        $(".txt-anwser-item").keydown(function(event) {            
            if (event.which == '192') {
                if (basicMP3Player.lastSound) 
	                basicMP3Player.stopSound(basicMP3Player.lastSound);
                basicMP3Player.handleClick({'target':$("#lst-exam-question").find('.lst-exam-question-item .sm2_button')[(objFastExam._currentID-1)]});
                event.preventDefault();
             }
            if (event.ctrlKey==true && (event.which == '118' || event.which == '86')) {
                popDiv.alert("Bạn không được dán nội dung vào đây!","Cảnh báo",1);
                event.preventDefault();
             }
        });

        
        $("#txt-anwser").unbind('keydown');
        $("#txt-anwser").unbind('contextmenu');
        $("#txt-anwser").keydown(function(event) {
            if (event.which == '192') {
                if (basicMP3Player.lastSound) 
	                basicMP3Player.stopSound(basicMP3Player.lastSound);
                basicMP3Player.handleClick({'target':$("#lst-exam-question").find('.lst-exam-question-item .sm2_button')[(objFastExam._currentID-1)]});
                event.preventDefault();
             }
            if (event.ctrlKey==true && (event.which == '118' || event.which == '86')) {
                popDiv.alert("Bạn không được dán nội dung vào đây!","Cảnh báo",1);
                event.preventDefault();
             }
        }).bind("contextmenu",function(e){
            e.preventDefault();
        });
        
        
        
        
        //khởi tạo nút start exam
        $("a[id='star-exam']").unbind("click");
        $("a[id='star-exam']").click(function(){
            //bat dau kt
            startExam();
            
            
        });
        //alert($($(".lst-exam-question").find("div")[0]).attr("id"));
        
        
        //gán cho sự kiện click cua nut next        
        $("#bnt-control").find("input[func='next']").unbind("click");
        $("#bnt-control").find("input[func='next']").click(function(){
               
               $(this).unbind("click");
               nextSent();
        });
        //gán cho sự kiện enter
        $("#txt-anwser").unbind("keypress");
        $("#txt-anwser").keypress(function(event){
          
            if(event.which==13)
            {
                $(this).unbind("keypress");
                
                nextSent();
            }
           
        });
        
        
        $("#txt-anwser-parent .txt-anwser-item").unbind("keypress");
        $("#txt-anwser-parent .txt-anwser-item").keypress(function(event){          
            if(event.which==13)//enter
            {                
                $(this).next(".txt-anwser-item").focus();
            }
           
        });
        $("#txt-anwser-parent .txt-anwser-item").last().keypress(function(event){          
            if(event.which==13)//enter
            {                
                $(this).unbind("keypress");
                nextSent();
            }
           
        });
    
        //gán sự kiện click vào div anwser
        $(".anws-exam b").unbind("click");
        $(".anws-exam b").click(function(){
            
                var parentDiv=$(this).parent();
                //luu lai gia tri hien tai
                _curranwser=formatInputText($(this).html());
                
                //thay tag b bang tag input
                $(this).replaceWith('<input type="text" value="'+_curranwser+'" class="txt-anwser" style="width:auto;">');
                //focus vào input đầu tiên
                $(parentDiv).find("input:first").focus().select();
                
                initControl();
                $(this).unbind("click");
            
        });
        //sự kiện out focus
        $(".txt-anwser").unbind("focusout");
        $(".txt-anwser").unbind("keypress");
        $(".txt-anwser").focusout(function(){
        
        
            var rsanwser=$(this).val();
            var regrepl=rsanwser.replace(/ /g,"");
            if(rsanwser=='' || regrepl=='')
            {
                rsanwser=_curranwser;
            }
            
            //$(this).parent().html(rsanwser);   
            $(this).replaceWith('<b style="color:green;cursor:pointer">'+formatInputText($.trim(rsanwser))+'</b>');
            initControl();        
            $(this).unbind("focusout");
        }).keypress(function(event){
            
            if(event.which==13)
            {
                
                var rsanwser=$(this).val();
                
                var regrepl=rsanwser.replace(/ /g,"");
                if(rsanwser=='' || regrepl=='')
                {
                    
                    rsanwser=_curranwser;
                }
                
                //$(this).parent().html(rsanwser);   
                $(this).replaceWith('<b style="color:green;cursor:pointer">'+formatInputText($.trim(rsanwser))+'</b>');
                initControl();        
                $(this).unbind("keypress");
            }
           
        });
        
        
   }
   
}
var objFastExam = new user_fast_exam();

$(document).ready(function(){
   
   
   

    //init button star
    objFastExam.initControl();
    //lấy cai gán vào id current
    var temp = $($(".lst-exam-question").find("div")[0]).attr("id");
    objFastExam._currentID=parseInt(temp.replace("block_item_",""));
    objFastExam._totalques=parseInt($("#lst-exam-question div[class='lst-exam-question-item']").size());       
    //fix trường hợp lưu cache trên FF
    $("#txt-anwser").attr("disabled",false);
    $("#txt-anwser").val('');
    
    objFastExam._cd=200;//parseInt($("#time-countdown").html());
    
    
    //alert('aaaaaa');
    if(!$('html').hasClass('signed-in'))
    {
      if(GetCookie('fastexamplaycount')!=1)
      {
        $("#note-register-to-play-1").show();
        $(".control #star-exam").show();
             
      }
      else
      {        
        $(".control #star-exam").remove();
        $("#note-register-to-play-2").show();
      }
    }
    else
    {
      $(".control #star-exam").show();
    }

    //kiểm tra đã làm bài tập xong chưa
    objFastExam._completeExam=1;
    window.onbeforeunload=function (){return objFastExam.checkCompleteExam();};
    
});

